package com.example.jline;

import org.jline.builtins.Completers;
import org.jline.reader.Candidate;
import org.jline.reader.Completer;
import org.jline.reader.EndOfFileException;
import org.jline.reader.LineReader;
import org.jline.reader.LineReaderBuilder;
import org.jline.reader.ParsedLine;
import org.jline.reader.UserInterruptException;
import org.jline.reader.impl.DefaultExpander;
import org.jline.reader.impl.DefaultParser;
import org.jline.reader.impl.completer.completer.ArgumentCompleter;
import org.jline.reader.impl.completer.completer.EnumCompleter;
import org.jline.reader.impl.completer.completer.FileNameCompleter;
import org.jline.reader.impl.completer.completer.NullCompleter;
import org.jline.reader.impl.completer.completer.StringsCompleter;
import org.jline.reader.impl.history.history.MemoryHistory;
import org.jline.terminal.Terminal;
import org.jline.terminal.TerminalBuilder;

import java.io.IOException;
import java.util.List;

/**
 * @author shanchong
 * @date 2021/3/21
 **/
public class ServerMain {

    public static void main(String[] args) throws IOException {
        Terminal terminal = TerminalBuilder.builder()
                .streams(System.in, System.out)
                .system(false)
                .build();
        LineReader lineReader = LineReaderBuilder.builder()
                .terminal(terminal)
//                .history(new MemoryHistory())
//                .parser(new DefaultParser())
                .completer(new ArgumentCompleter(new EnumCompleter(Command.class), new FileNameCompleter()))
//                .completer(new ArgumentCompleter( new StringsCompleter("CREATE"), NullCompleter.INSTANCE))
                .build();
        String prompt = "command> ";
        while (true) {
            String line;
//            try {
                line = lineReader.readLine(prompt);
////                System.out.println(line);
//            } catch (UserInterruptException e) {
//                // Do nothing
//            } catch (EndOfFileException e) {
//                System.out.println("\nBye.");
//                return;
        }

    }

}
